package com.cqc.buglyupdate01;

import android.app.Activity;
import android.app.Application;
import android.util.Log;

import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;

import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${cqc} on 2017/6/6.
 */

public class MyApplication extends Application {


    private static List<Activity> activityList = new ArrayList<>();

    @Override
    public void onCreate() {
        super.onCreate();
//        Bugly.init(getApplicationContext(), "bc9e2b57b8", false);
//        Beta.upgradeCheckPeriod = 60 * 1000;

    }


    public static void addActivity(Activity activity) {
        if (activity != null) {
            activityList.add(activity);
        }
    }

    public static void removeActivity(Activity activity) {
        if (activity != null) {
            activityList.remove(activity);
            activity.finish();
        }
    }


    public static void exitApp() {
        for (Activity activity : activityList) {
            if (activity != null) {
                activity.finish();
            }
        }
        System.exit(0);
    }


    public static void exitApp2() {
        for (Activity activity : activityList) {
            if (activity != null) {
                activity.finish();
            }
        }
        android.os.Process.killProcess(android.os.Process.myPid());
    }
}
